SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[usp_AddEmailMark]
(
	@param_Admin_LoginID VarChar(50),
	@param_name VarChar(50),
	@param_introduction Varchar(max),
	@param_is_default bit,
	@param_add_time smalldatetime,
	@param_user_add VarChar(50)

	)
	
AS
	/* SET NOCOUNT ON */
	 DECLARE @Count INT
                 SET @Count = (
                        SELECT   COUNT(*)
                        FROM     dbo.JOL_EmailManagement_Mark
                        WHERE    Admin_LoginID = @param_Admin_LoginID and name=@param_name
                        )
                IF @Count = 0 
                insert into dbo.JOL_EmailManagement_Mark
                (Admin_LoginID,name,introduction,is_default,add_time,user_add)
                values
                
               (@param_Admin_LoginID,@param_name,@param_introduction,@param_is_default,@param_add_time,@param_user_add )
                    
                   IF @param_is_default='TRUE'
						update dbo.JOL_EmailManagement_Mark 
						set is_default='false' where Admin_LoginID=@param_Admin_LoginID and  is_default='TRUE' and name<>@param_name
                   
                ELSE
	
				 SELECT  '该标签已存在'
	RETURN
GO
